home *** CD-ROM | disk | FTP | other *** search
- Path: lrz-muenchen.de!news
- From: watzka@stat.uni-muenchen.de (Kurt Watzka)
- Newsgroups: comp.lang.c
- Subject: Re: Help:what is wrong this code?
- Date: 6 Apr 1996 01:31:47 GMT
- Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
- Distribution: world
- Message-ID: <4k4hi3$5hm@sparcserver.lrz-muenchen.de>
- References: <4k3p3q$n76@brahms.udel.edu>
- NNTP-Posting-Host: sun2.lrz-muenchen.de
-
- yuehong@brahms.udel.edu (Yue-hong Zheng) writes:
-
-
- >Why it give me 0.0000?
-
- >#include <stdio.h>
- >main () {
- >double a=9.008;
- >printf("%f\n",sqrt(a));
- >return 0;
- >}
-
- Could the FAQ "I'm trying to take some square roots, but I'm
- getting crazy numbers" be somehow related to your question?
- I mean, this is almost exactly the question you ask, and the
- answer given in the FAQ is the right answer for your problem.
-
- Hint: sqrt() in not declared in <stdio.h> and the description
- "function taking an unspecified number of parameters and returning
- int", i.e. the default type for a function that has not been
- previously declared, is not exactly correct for sqrt(). You
- _need_ a declaration for all functions that are either variadic
- or do not return "int".
-
- Kurt
- --
- | Kurt Watzka Phone : +49-89-2180-6254
- | watzka@stat.uni-muenchen.de
-
-
-